//数据库集合的相关配置
//1.定义数据集合的结构：定义出集合中数据有哪些属性，属性的值是什么类型
const { Schema, model } = require('mongoose');
const moment =require('moment')

const parkingsSchema = new Schema({
    address: String,
    number: String,
    property: String,
    cycle: String,
    price: String,
    state: {
        type: Number,
        default: 1
    },
    delete:{
        type:Boolean,
        default:false
    },
    lessorsId: {
        type: Schema.Types.ObjectId,
        //ref用于设置要关联的集合的模型名称
        ref: 'lessorsModel'
    },
    adminsId:{
        type: Schema.Types.ObjectId,
        ref: 'adminsModel'
    },
    time:{
        type:String,
        default:moment().format('YYYY/MM/DD HH:mm')
    }
}, { versionKey: false })
//2.定义数据集合的模型：将schema和数据库中的集合关联起来
//model('模型名称','schema名称','数据库中的集合名称');
const parkingsModel = model('parkingsModel', parkingsSchema, 'parkings');
module.exports.parkingsModel = parkingsModel;